#include <stdio.h>
double A1(double[4]), A2(double[9]);
int main()
{
    int n;
    double det, a[4],b[9];
    printf("请输入行列式的行数");
    scanf("%d",&n);
    switch(n) 
    {
        case 2:
        printf("分别输入2阶行列式的各值");
        scanf("%lf %lf %lf %lf,",&a[0],&a[1],&a[2],&a[3]);
        printf("输入行列式为:\n");
        printf("%lf %lf\n,",a[0],a[1]);
        printf("%lf %lf\n," ,a[2],a[3]);
         det=A1(a);
         printf("输出矩阵的值%lf",det);
         
         break;


        case 3:
        printf("分别输入3阶行列式的各值");
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf,",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5],&b[6],&b[7],&b[8]);
        printf("输入行列式：\n");
        printf("%lf %lf %lf\n,",b[0],b[1],b[2]);
        printf("%lf %lf %lf\n,",b[3],b[4],b[5]);
        printf("%lf %lf %lf\n,",b[6],b[7],b[8]);

        det=A2(b);
        printf("输出矩阵的值%lf",det);
        break;
    }
}
double A1(double m[4])
{
    return m[0]*m[3]-m[1]*m[2];
}


double A2(double n[9])
{
    return n[4]*n[8]-n[5]*n[7]-n[3]*n[8]+n[5]*n[6]+n[3]*n[7]-n[4]*n[6];
           }


